/*************************************************************************
	> File Name: 222-2.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-05-14 10:45:16
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define L(ind) (tree[ind].lchild)
#define R(ind) (tree[ind].rchild)
#define C(ind) (tree[ind].c)

struct Node {
    int c, lchild, rchild;
} tree[20005];
int root = 1, node_cnt = 1;
int n, m, a[10005];

inline int getNewNode() {
    return ++node_cnt;
}

void UP(int ind) {
    C(ind) = max(C(L(ind)), C(R(ind)));
    return ;
}

void build_tree(int ind, int l, int r) {
    if (l == r) {
        tree[ind].c = a[l];
        return ;
    }
    int mid = (l + r) / 2;
    L(ind) = getNewNode();
    R(ind) = getNewNode();
    build_tree(L(ind), l, mid);
    build_tree(R(ind), mid + 1, r);
    UP(ind);
    return ;
}

void modify(int ind, int l, int r, int x, int y) {
    if (l == r) {
        C(ind) = y;
        return ;
    }
    int mid = (l + r) / 2;
    if (x <= mid) modify(L(ind), l, mid, x, y);
    else modify(R(ind), mid + 1, r, x, y);
    UP(ind);
    return ;
}

int query(int ind, int l, int r, int x, int y) {
    if (l >= x && r <= y) {
        return C(ind);
    }
    int mid = (l + r) / 2;
    int ans = -2147483648;
    if (x <= mid) ans = max(ans, query(L(ind), l, mid, x, y));
    if (y > mid) ans = max(ans, query(R(ind), mid + 1, r, x, y));
    return ans;
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    build_tree(root, 1, n);
    for (int i = 1, a, b, c; i <= m; i++) {
        scanf("%d%d%d", &a, &b, &c);
        if (a == 1) {
            if (b <= c) modify(root, 1, n, b, c);
        } else {
            if (b <= c) printf("%d\n", query(root, 1, n, b, c));
            else printf("-2147483648\n");
        }
    }
    return 0;
}
